<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>手机启动页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">

    <style>
        .layui-hide{  /*最后的pic为字段的field*/
            height: 100%;
            max-width: 100%;
        }
        .layui-table-cell{
            height:auto !important;
        }
    </style>
</head>
<body>


<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">手机启动页</div>
                <div class="layui-card-body">


                    <table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate" lay-size="lg">


                    </table>

                    <script type="text/html" id="test-table-operate-barDemo">
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<!--添加弹窗-->

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','table','laydate','set','upload'], function(){
        $ = layui.jquery;
        var table = layui.table
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,upload = layui.upload
            ,laydate = layui.laydate
            ,form = layui.form;

        table.render({
            elem: '#test-table-operate'
            ,url: "{:url('Start/all')}"
            ,height: 'full-155'
            ,cols: [[
                {field:'id',width:100,align:"center",  title: 'ID'}
                ,{field:'app_img',align:"center",title: '手机启动图片',style:"height:150px;",templet:function(d){
                        return "<img src='" +d.app_img+ "' style='display:block;width:205px;height:123px;'>"
                    }}
                    ,{align:'center',width:350, title: '操作',fixed: 'right', toolbar: '#test-table-operate-barDemo'}
            ]]
            ,page: true
            ,limit: 20
        });

        form.render(null, 'component-form-group');

        laydate.render({
            elem: '#LAY-component-form-group-date'
        });

        var uploadInst = upload.render({
            elem: '#guide_card_thumb1'
            ,url: "{:url('Common/upload')}"
            ,before: function(obj){
                $('#upload_thumb_img_div1').show();
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#upload_thumb_img1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){

                if (res.code == 1){
                    $('#banner_img').val(res.data);
                    return layer.msg(res.msg);
                }else{
                    return layer.msg(res.msg);
                }
            }
        });
        //监听工具条
        table.on('tool(test-table-operate)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                window.location.href="{:url('Start/editAll')}"+'?id='+data.id;
            }
        });

        var $ = layui.$, active = {
            searchUserButton:function(){
                var ad_type  = $('#ad_type').val();
                table.reload('test-table-operate', {
                    where: {
                        type: ad_type
                    }
                    ,page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
                //return false;
            },
            addadmin: function() {
                var addmodal = layer.open({
                    title: '添加轮播图'
                    , type: 1
                    , shadeClose: true
                    ,zIndex:10
                    , content: $('#addmodal')
                });
                layer.full(addmodal);
            }
        };
        //绑定点击事件
        $('.test-table-operate-btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


    });



</script>


</body>
</html>